package com.wangshuqi.boot.controller;

import com.alibaba.fastjson.JSON;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class SessionController {

    @RequestMapping("/get")
    public String getSessionAttribute(HttpServletRequest request) {
        Object userInfo = request.getSession().getAttribute("userInfo");
        if (userInfo != null) {
            return "📦 获取Session属性: " + JSON.toJSONString(userInfo);
        } else {
            return "❗ Session属性不存在。";
        }
    }
}
